package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/5 17:06
 * @description
 */
public class Code14 {
    public static void main(String[] args) {
        System.out.println("".charAt(2));
    }

    public String longestCommonPrefix(String[] strs) {
        StringBuilder sb = new StringBuilder();
        int i = 0;
        while (true) {
            char c;
            try {
                c = strs[0].charAt(i);
                for (int j = 1; j < strs.length; j++) {
                    if (strs[j].charAt(i) != c) {
                        return sb.toString();
                    }
                }
            } catch (Exception e) {
                return sb.toString();
            }
            sb.append(c);
            i++;
        }
    }
}
